package com.goods.business.converter;

import com.goods.common.model.business.ProductCategory;
import com.goods.common.vo.business.ProductCategoryTreeNodeVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

public class ProductCategoryConverter {

    //将数据库查出的数据转换成ProductCategoryTreeNodeVO  类
    public static List<ProductCategoryTreeNodeVO> productCategoryTreeNodeVO(List<ProductCategory> productCategorys){

        List<ProductCategoryTreeNodeVO> productCategoryTreeNodeVOS = new ArrayList<>();
        if (!CollectionUtils.isEmpty(productCategorys)){
            for (ProductCategory productCategory : productCategorys) {
                ProductCategoryTreeNodeVO productCategoryTreeNodeVO = new ProductCategoryTreeNodeVO();
                BeanUtils.copyProperties(productCategory,productCategoryTreeNodeVO);
                productCategoryTreeNodeVOS.add(productCategoryTreeNodeVO);
            }
        }
        return productCategoryTreeNodeVOS;
    }

}
